package com.jackrain.nea.wms.lts;

import com.github.ltsopensource.jobclient.JobClient;
import com.github.ltsopensource.spring.JobClientFactoryBean;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Slf4j
@Configuration
public class JobClientConfig {

    @Bean(name = "jobClient")
    public JobClient getJobClient() throws Exception {

        JobClientFactoryBean factoryBean = new JobClientFactoryBean();
        factoryBean.setLocations("config/lts.properties");
        factoryBean.setJobCompletedHandler(new JobCompletedHandlerImpl());
        factoryBean.afterPropertiesSet();
        factoryBean.start();
        log.debug("JobClient start");
        return factoryBean.getObject();
    }
}
